// i.r(t),
//   i.d(t, {
//     AnnotationSearchCommand: () => AnnotationSearchCommand,
//     AnnotationSearchToggledMessage: () =>
//       AnnotationSearchToggledMessage,
//     AnnotationsViewData: () => AnnotationsViewData,
//     CancelAnnotationSearchCommand: () => CancelAnnotationSearchCommand,
//     default: () => a
//   })
import Module from "./Module"

import { AnnotationSearchToggledMessage } from "../message/annotations.message"
import AnnotationsViewData from "../data/AnnotationsViewData"
import { AnnotationSearchCommand, CancelAnnotationSearchCommand } from "../command/annotation.command"
export default class AnnotationsModule extends Module {
  cancelSearch: () => Promise<void>
  viewData: any
  engine: any
  searchAnnotations: (e: any) => Promise<void>
  constructor() {
    super(...arguments)
    this.name = "annotations"
    this.cancelSearch = async () => {
      this.viewData.searchBlock && (this.viewData.setSearchBlock(null), this.engine.broadcast(new AnnotationSearchToggledMessage(!1)))
    }
    this.searchAnnotations = async e => {
      const t = e.searchBlock
      this.viewData.setSearchBlock(t), this.engine.broadcast(new AnnotationSearchToggledMessage(!0))
    }
  }
  async init(e, t) {
    this.viewData = new AnnotationsViewData()
    this.engine = t
    t.market.register(this, AnnotationsViewData, this.viewData)
    this.bindings.push(
      t.commandBinder.addBinding(AnnotationSearchCommand, this.searchAnnotations),
      t.commandBinder.addBinding(CancelAnnotationSearchCommand, this.cancelSearch)
    )
  }
  dispose(e) {
    this.bindings.forEach(e => {
      e.cancel()
    })
    this.bindings = []
    this.cancelSearch()
    super.dispose(e)
  }
  onUpdate() {}
}
